Skip to content

Commit 7374f54

Browse files
committed
change data acquisition source
1 parent e789ac5 commit 7374f54

File tree

5 files changed

+38
-48
lines changed

5 files changed

+38
-48
lines changed

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

+2
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
"dt",
3333
"em",
3434
"embed",
35+
"fencedframe",
3536
"fieldset",
3637
"figcaption",
3738
"figure",
@@ -73,6 +74,7 @@
7374
"output",
7475
"p",
7576
"picture",
77+
"portal",
7678
"pre",
7779
"progress",
7880
"q",

Diff for: package.json

+1
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@
9090
"eslint-plugin-vue": "file:.",
9191
"espree": "^9.6.1",
9292
"events": "^3.3.0",
93+
"jsdom": "^22.0.0",
9394
"markdownlint-cli": "^0.42.0",
9495
"mocha": "^10.7.3",
9596
"nyc": "^17.1.0",

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

+2
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,8 @@ const invalidElements = [
272272
'Defs',
273273
'desc',
274274
'Desc',
275+
'discard',
276+
'Discard',
275277
'ellipse',
276278
'Ellipse',
277279
'feBlend',

Diff for: tools/update-resources.js

+32-47
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,18 @@
11
'use strict'
22

33
const fs = require('fs')
4-
const tsParser = require('@typescript-eslint/parser')
4+
const jsdom = require('jsdom')
55
const { httpGet } = require('./lib/http')
66

7-
/**
8-
* @typedef {import('@typescript-eslint/types').TSESTree.TSInterfaceDeclaration} TSInterfaceDeclaration
9-
*/
10-
117
main()
128

139
async function main() {
14-
const libDomDTsText = await httpGet(
15-
'https://unpkg.com/typescript/lib/lib.dom.d.ts'
16-
)
17-
const rootNode = tsParser.parse(libDomDTsText, {
18-
loc: true,
19-
range: true
20-
})
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+
2116
updateDeprecatedHTMLElements()
2217
updateHTMLElements()
2318
updateSVGElements()
@@ -30,15 +25,17 @@ async function main() {
3025
'../lib/utils/deprecated-html-elements.json'
3126
)
3227
const elements = new Set()
33-
/** @type {TSInterfaceDeclaration} */
34-
const interfaceDeclaration = rootNode.body.find(
35-
(body) =>
36-
body.type === 'TSInterfaceDeclaration' &&
37-
body.id.name === 'HTMLElementDeprecatedTagNameMap'
28+
29+
const domDl = jsdom.JSDOM.fragment(obsoleteHtml).querySelector(
30+
'[id="non-conforming-features"] ~ dl'
3831
)
32+
for (const code of domDl.querySelectorAll('dt code')) {
33+
const name = code.textContent.trim()
34+
if (name) elements.add(name)
35+
}
3936

40-
for (const name of extractPropNames(interfaceDeclaration)) {
41-
elements.add(name)
37+
if (elements.size === 0) {
38+
throw new Error('No deprecated HTML elements found')
4239
}
4340

4441
fs.writeFileSync(
@@ -59,20 +56,21 @@ async function main() {
5956
const deprecatedHtmlElements = new Set(
6057
require('../lib/utils/deprecated-html-elements.json')
6158
)
62-
/** @type {TSInterfaceDeclaration} */
63-
const interfaceDeclaration = rootNode.body.find(
64-
(body) =>
65-
body.type === 'TSInterfaceDeclaration' &&
66-
body.id.name === 'HTMLElementTagNameMap'
67-
)
6859

69-
for (const name of extractPropNames(interfaceDeclaration)) {
60+
for (const [name, element] of Object.entries(bcd.html.elements)) {
7061
if (deprecatedHtmlElements.has(name)) {
7162
continue
7263
}
64+
if (element.__compat.status.deprecated) {
65+
continue
66+
}
7367
elements.add(name)
7468
}
7569

70+
if (elements.size === 0) {
71+
throw new Error('No HTML elements found')
72+
}
73+
7674
fs.writeFileSync(
7775
HTML_ELEMENTS_PATH,
7876
`${JSON.stringify([...elements].sort(), null, 2)}\n`,
@@ -86,35 +84,22 @@ async function main() {
8684
function updateSVGElements() {
8785
const SVG_ELEMENTS_PATH = require.resolve('../lib/utils/svg-elements.json')
8886
const elements = new Set()
89-
/** @type {TSInterfaceDeclaration} */
90-
const interfaceDeclaration = rootNode.body.find(
91-
(body) =>
92-
body.type === 'TSInterfaceDeclaration' &&
93-
body.id.name === 'SVGElementTagNameMap'
94-
)
9587

96-
for (const name of extractPropNames(interfaceDeclaration)) {
88+
for (const [name, element] of Object.entries(bcd.svg.elements)) {
89+
if (element.__compat.status.deprecated) {
90+
continue
91+
}
9792
elements.add(name)
9893
}
9994

95+
if (elements.size === 0) {
96+
throw new Error('No SVG elements found')
97+
}
98+
10099
fs.writeFileSync(
101100
SVG_ELEMENTS_PATH,
102101
`${JSON.stringify([...elements].sort(), null, 2)}\n`,
103102
'utf8'
104103
)
105104
}
106105
}
107-
108-
/**
109-
* @param {TSInterfaceDeclaration} node
110-
*/
111-
function* extractPropNames(node) {
112-
for (const m of node.body.body) {
113-
if (
114-
(m.type === 'TSPropertySignature' || m.type === 'TSMethodSignature') &&
115-
(m.key.type === 'Identifier' || m.key.type === 'Literal')
116-
) {
117-
yield m.key.type === 'Identifier' ? m.key.name : `${m.key.value}`
118-
}
119-
}
120-
}

Diff for: tools/update.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ require('./update-lib-flat-configs')
1111
require('./update-lib-index')
1212
require('./update-docs')
1313
require('./update-docs-rules-index')
14-
require('./update-resources')
1514

1615
if (process.env.IN_VERSION_SCRIPT) {
1716
require('./update-vue3-export-names')
17+
require('./update-resources')
1818
}

0 commit comments

Comments
 (0)