Skip to content

Commit 5b74592

Browse files
committed
Update dev-dependencies
1 parent 1f43c76 commit 5b74592

File tree

4 files changed

+57
-68
lines changed

4 files changed

+57
-68
lines changed

build.js

Lines changed: 37 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
1-
import fs from 'fs'
2-
import https from 'https'
1+
import fs from 'node:fs'
2+
import https from 'node:https'
33
import {bail} from 'bail'
44
import concat from 'concat-stream'
55
import alphaSort from 'alpha-sort'
6-
import unified from 'unified'
6+
import {unified} from 'unified'
77
import parse from 'rehype-parse'
8-
// @ts-ignore Remove when types are added
9-
import q from 'hast-util-select'
10-
// @ts-ignore Remove when types are added
11-
import toString from 'hast-util-to-string'
12-
// @ts-ignore Remove when types are added
13-
import ev from 'hast-util-is-event-handler'
8+
import {select, selectAll} from 'hast-util-select'
9+
import {toString} from 'hast-util-to-string'
10+
import {isEventHandler} from 'hast-util-is-event-handler'
1411

1512
/**
1613
* @typedef {import('http').IncomingMessage} IncomingMessage
@@ -20,13 +17,13 @@ import ev from 'hast-util-is-event-handler'
2017
* @typedef {Object.<string, Array.<string>>} Map
2118
*/
2219

23-
var proc = unified().use(parse)
20+
const proc = unified().use(parse)
2421

25-
var actual = 0
26-
var expected = 3
22+
let actual = 0
23+
const expected = 3
2724

2825
/** @type {Map} */
29-
var all = {}
26+
const all = {}
3027

3128
https.get('https://www.w3.org/TR/SVG11/attindex.html', onsvg1)
3229
https.get('https://www.w3.org/TR/SVGTiny12/attributeTable.html', ontiny)
@@ -42,11 +39,11 @@ function onsvg1(response) {
4239
* @param {Buffer} buf
4340
*/
4441
function onconcat(buf) {
45-
var tree = proc.parse(buf)
42+
const tree = proc.parse(buf)
4643
/** @type {Map} */
47-
var map = {}
44+
const map = {}
4845
/** @type {Element[]} */
49-
var nodes = q.selectAll('.property-table tr', tree)
46+
const nodes = selectAll('.property-table tr', tree)
5047

5148
if (nodes.length === 0) {
5249
throw new Error('Couldn’t find rows in SVG 1')
@@ -61,19 +58,14 @@ function onsvg1(response) {
6158
*/
6259
function each(node) {
6360
/** @type {Element[]} */
64-
var elements = q.selectAll('.element-name', node)
61+
const elements = selectAll('.element-name', node)
6562

66-
q.selectAll('.attr-name', node).forEach(every)
67-
68-
/**
69-
* @param {string} name
70-
*/
71-
function every(name) {
63+
selectAll('.attr-name', node).forEach((name) => {
7264
elements
7365
.map(toString)
7466
.map(clean)
7567
.forEach(add(map, clean(toString(name))))
76-
}
68+
})
7769
}
7870

7971
/**
@@ -96,11 +88,11 @@ function ontiny(response) {
9688
* @param {Buffer} buf
9789
*/
9890
function onconcat(buf) {
99-
var tree = proc.parse(buf)
91+
const tree = proc.parse(buf)
10092
/** @type {Map} */
101-
var map = {}
93+
const map = {}
10294
/** @type {Element[]} */
103-
var nodes = q.selectAll('#attributes .attribute', tree)
95+
const nodes = selectAll('#attributes .attribute', tree)
10496

10597
if (nodes.length === 0) {
10698
throw new Error('Couldn’t find nodes in SVG Tiny')
@@ -115,11 +107,11 @@ function ontiny(response) {
115107
*/
116108
function each(node) {
117109
/** @type {Element[]} */
118-
var all = q.selectAll('.element', node)
110+
const all = selectAll('.element', node)
119111

120112
all
121113
.map(toString)
122-
.forEach(add(map, toString(q.select('.attribute-name', node))))
114+
.forEach(add(map, toString(select('.attribute-name', node))))
123115
}
124116
}
125117
}
@@ -134,11 +126,11 @@ function onsvg2(response) {
134126
* @param {Buffer} buf
135127
*/
136128
function onconcat(buf) {
137-
var tree = proc.parse(buf)
129+
const tree = proc.parse(buf)
138130
/** @type {Map} */
139-
var map = {}
131+
const map = {}
140132
/** @type {Element[]} */
141-
var nodes = q.selectAll('tbody tr', tree)
133+
const nodes = selectAll('tbody tr', tree)
142134

143135
if (nodes.length === 0) {
144136
throw new Error('Couldn’t find nodes in SVG 2')
@@ -153,11 +145,11 @@ function onsvg2(response) {
153145
*/
154146
function each(node) {
155147
/** @type {Element[]} */
156-
var all = q.selectAll('.element-name span', node)
148+
const all = selectAll('.element-name span', node)
157149

158150
all
159151
.map(toString)
160-
.forEach(add(map, toString(q.select('.attr-name span', node))))
152+
.forEach(add(map, toString(select('.attr-name span', node))))
161153
}
162154
}
163155
}
@@ -176,7 +168,7 @@ function done(map) {
176168
if (actual === expected) {
177169
fs.writeFile(
178170
'index.js',
179-
'export var svgElementAttributes = ' +
171+
'export const svgElementAttributes = ' +
180172
JSON.stringify(sort(all), null, 2) +
181173
'\n',
182174
bail
@@ -192,7 +184,7 @@ function done(map) {
192184
*/
193185
function add(map, name) {
194186
if (
195-
ev(name) ||
187+
isEventHandler(name) ||
196188
name === 'role' ||
197189
name.slice(0, 5) === 'aria-' ||
198190
name.slice(0, 3) === 'ev:' ||
@@ -208,7 +200,7 @@ function add(map, name) {
208200
* @param {string} tagName Element name
209201
*/
210202
function fn(tagName) {
211-
var attributes = map[tagName] || (map[tagName] = [])
203+
const attributes = map[tagName] || (map[tagName] = [])
212204

213205
if (!attributes.includes(name)) {
214206
attributes.push(name)
@@ -224,11 +216,11 @@ function add(map, name) {
224216
*/
225217
function clean(map) {
226218
/** @type {Map} */
227-
var result = {}
219+
let result = {}
228220
/** @type {Array.<string>} */
229-
var list = []
221+
const list = []
230222
/** @type {Array.<string>} */
231-
var globals = []
223+
const globals = []
232224

233225
// Find all used attributes.
234226
Object.keys(map).forEach(function (tagName) {
@@ -241,9 +233,9 @@ function clean(map) {
241233

242234
// Find global attributes.
243235
list.forEach(function (attribute) {
244-
var global = true
236+
let global = true
245237
/** @type {string} */
246-
var key
238+
let key
247239

248240
for (key in map) {
249241
if (!map[key].includes(attribute)) {
@@ -265,7 +257,7 @@ function clean(map) {
265257
Object.keys(map)
266258
.sort()
267259
.forEach(function (tagName) {
268-
var attributes = map[tagName]
260+
const attributes = map[tagName]
269261
.filter(function (attribute) {
270262
return !globals.includes(attribute)
271263
})
@@ -303,7 +295,7 @@ function merge(left, right) {
303295
* @param {Map} map
304296
*/
305297
function cleanAll(map) {
306-
var globals = map['*']
298+
const globals = map['*']
307299

308300
Object.keys(map).forEach(function (tagName) {
309301
if (tagName !== '*') {
@@ -320,7 +312,7 @@ function cleanAll(map) {
320312
*/
321313
function sort(map) {
322314
/** @type {Map} */
323-
var result = {}
315+
const result = {}
324316

325317
Object.keys(map)
326318
.sort(alphaSort())

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export var svgElementAttributes = {
1+
export const svgElementAttributes = {
22
'*': [
33
'about',
44
'class',

package.json

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -31,27 +31,27 @@
3131
"index.js"
3232
],
3333
"devDependencies": {
34-
"@types/concat-stream": "^1.6.0",
35-
"@types/hast": "^2.3.1",
36-
"@types/node": "^14.14.37",
37-
"@types/tape": "^4.13.0",
38-
"alpha-sort": "^4.0.0",
34+
"@types/concat-stream": "^1.0.0",
35+
"@types/hast": "^2.0.0",
36+
"@types/node": "^16.0.0",
37+
"@types/tape": "^4.0.0",
38+
"alpha-sort": "^5.0.0",
3939
"bail": "^2.0.0",
4040
"c8": "^7.0.0",
4141
"concat-stream": "^2.0.0",
42-
"hast-util-is-event-handler": "^1.0.0",
43-
"hast-util-select": "^4.0.0",
44-
"hast-util-to-string": "^1.0.0",
42+
"hast-util-is-event-handler": "^2.0.0",
43+
"hast-util-select": "^5.0.0",
44+
"hast-util-to-string": "^2.0.0",
4545
"prettier": "^2.0.0",
46-
"rehype-parse": "^7.0.0",
47-
"remark-cli": "^9.0.0",
48-
"remark-preset-wooorm": "^8.0.0",
49-
"rimraf": "^3.0.2",
46+
"rehype-parse": "^8.0.0",
47+
"remark-cli": "^10.0.0",
48+
"remark-preset-wooorm": "^9.0.0",
49+
"rimraf": "^3.0.0",
5050
"tape": "^5.0.0",
51-
"type-coverage": "^2.17.0",
52-
"typescript": "^4.2.3",
53-
"unified": "^9.0.0",
54-
"xo": "^0.38.0"
51+
"type-coverage": "^2.0.0",
52+
"typescript": "^4.0.0",
53+
"unified": "^10.0.0",
54+
"xo": "^0.46.0"
5555
},
5656
"scripts": {
5757
"prepack": "npm run build && npm run format",
@@ -73,9 +73,6 @@
7373
"xo": {
7474
"prettier": true,
7575
"rules": {
76-
"import/no-mutable-exports": "off",
77-
"no-var": "off",
78-
"prefer-arrow-callback": "off",
7976
"unicorn/no-array-for-each": "off",
8077
"unicorn/no-array-callback-reference": "off"
8178
}

test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import assert from 'assert'
1+
import assert from 'node:assert'
22
import test from 'tape'
33
import {svgElementAttributes} from './index.js'
44

@@ -13,10 +13,10 @@ test('svgElementAttributes', function (t) {
1313

1414
t.doesNotThrow(function () {
1515
for (const name of Object.keys(svgElementAttributes)) {
16-
var props = svgElementAttributes[name]
16+
const props = svgElementAttributes[name]
1717

1818
for (const prop of props) {
19-
var label = prop + ' in ' + name
19+
const label = prop + ' in ' + name
2020
assert.strictEqual(typeof prop, 'string', label + ' should be string')
2121
assert.strictEqual(prop, prop.trim(), label + ' should be trimmed')
2222
assert.ok(/^[a-z][a-z\d-]*$/i.test(prop), label + ' should be `a-z-`')

0 commit comments

Comments
 (0)